import 'package:flutter/material.dart';

import '../../../helper.dart';

class SearchBar extends StatelessWidget {
  SearchBar({this.textCtrl, this.hintText});
  final TextEditingController textCtrl;
  final String hintText;
  final double height = setWidth(80);
  @override
  Widget build(BuildContext context) {
    return Container(
      height: height,
      margin: EdgeInsets.symmetric(horizontal: setWidth(16)),
      decoration: BoxDecoration(
          color: Color(0xffF7F7F7),
          borderRadius: BorderRadius.circular(height / 2)),
      child: TextField(
        controller: textCtrl,
        maxLines: 1,
        style: TextStyle(
          color: Color(0xff222222),
          fontSize: 14,
        ),
        decoration: InputDecoration(
          border: InputBorder.none,
          contentPadding: EdgeInsets.all(0),
          hintText: hintText,
          hintStyle: TextStyle(
            color: Color(0xffcccccc),
            fontSize: 14,
          ),
          enabledBorder: OutlineInputBorder(
            // 设置输入框可编辑时的边框样式
            borderRadius:
                BorderRadius.all(Radius.circular(height / 2)), // 设置边框四个角的弧度
            borderSide: BorderSide.none,
          ),
          focusedBorder: OutlineInputBorder(
            // 用来配置输入框获取焦点时的颜色
            borderRadius:
                BorderRadius.all(Radius.circular(height / 2)), // 设置边框四个角的弧度
            borderSide: BorderSide.none,
          ),
          prefixIcon: InkWell(
            onTap: () {},
            child: Container(
              width: setWidth(40),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(setWidth(28)),
                  bottomLeft: Radius.circular(setWidth(28)),
                ),
              ),
              alignment: Alignment.center,
              child: Icon(
                Icons.search,
                color: Color(0xffcccccc),
                size: setWidth(40),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
